from django import template
from nmj.scanners.tmdb import to_unicode

register = template.Library()

@register.filter
def truncate(value, limit):
	try:
		value = to_unicode(value)
		limit = int(limit)
		if len(value) <= limit:
			return value
		return value[:limit - 3] + '...'
	except:
		import traceback
		return traceback.format_exc()

